home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 08 - 1992 / 08.03 Jul 92 / TextBoxer / TextBoxer.c next >
Encoding:
C/C++ Source or Header  |  1992-06-30  |  1.4 KB  |  74 lines  |  [TEXT/KAHL]

  1. #define kVisible            false
  2. #define kMoveToFront        (WindowPtr)-1L
  3. #define kNoGoAway            false
  4. #define kNilRefCon            0L
  5. #define kPascalString        "\pAll applaud the strongly-jawed"
  6. #define kFontSize            12
  7. #define kBottomOffset        7
  8. #define kLeftOffset            7
  9.  
  10. void            ToolBoxInit( void );
  11. WindowPtr        WindowInit( void );
  12.  
  13. /****************** main ************/
  14. main()
  15. {
  16.     Rect            shapeRect;
  17.     WindowPtr    window;
  18.     
  19.     ToolBoxInit();
  20.     window = WindowInit();
  21.     
  22.     shapeRect = window->portRect;
  23.     
  24.     InsetRect( &shapeRect, 5, 5 );
  25.     FrameRect( &shapeRect );
  26.     
  27.     InsetRect( &shapeRect, 2, 2 );
  28.     FrameRect( &shapeRect );
  29.     
  30.     TextFont( monaco );
  31.     TextSize( kFontSize );
  32.     MoveTo( shapeRect.left + kLeftOffset,
  33.         shapeRect.bottom - kBottomOffset );
  34.     DrawString( kPascalString );
  35.     
  36.     while ( ! Button() ) ;
  37. }
  38.  
  39. /****************** ToolBoxInit ***********/
  40. void    ToolBoxInit( void )
  41. {
  42.     InitGraf( &thePort );
  43.     InitFonts();
  44.     InitWindows();
  45.     InitMenus();
  46.     TEInit();
  47.     InitDialogs( nil );
  48.     InitCursor();
  49. }
  50.  
  51. /****************** WindowInit *************/
  52. WindowPtr    WindowInit( void )
  53. {
  54.     WindowPtr    window;
  55.     Rect            windowRect;
  56.     
  57.     SetRect( &windowRect, 20, 40, 260, 74 );
  58.  
  59.     window = NewWindow( nil, &windowRect, "\pBox o’ Text",
  60.                 kVisible, documentProc, kMoveToFront,
  61.                 kNoGoAway, kNilRefCon );
  62.     
  63.     if ( window == nil )
  64.     {
  65.         SysBeep( 10 );    /*  Couldn’t create a window!!!  */
  66.         ExitToShell();
  67.     }
  68.     
  69.     ShowWindow( window );
  70.     SetPort( window );
  71.     
  72.     return( window );
  73. }
  74.